import 'package:flutter/material.dart';

//  提供可以删除的展示chip
// 带删除功能的 input chip
class FilterInputChip extends StatefulWidget {
  final List<String> inputs;
  final String query;
  final VoidCallback onDeleted;

  FilterInputChip({@required this.inputs, this.query, @required this.onDeleted})
      : assert(inputs != null && onDeleted != null);

  _FilterInputChipState createState() => _FilterInputChipState();
}



class _FilterInputChipState extends State<FilterInputChip> {
  final List<String> _lists = <String>[
   
  ];

  List<String> _inputLists = <String>[];

  Iterable<Widget> get inputWidget sync* {
    for (String value in widget.inputs) {
      _inputLists.add(value);
      yield Padding(
        padding: const EdgeInsets.all(4.0),
        child: InputChip(
        
          label: Text(value,maxLines: 1,overflow: TextOverflow.ellipsis,),
          onSelected: (bool value){
              
          },
          // 删除某个向导
          onDeleted: () {
            widget.onDeleted();
            setState(() {
              _lists.remove(value);
              widget.inputs.remove(value);
            });
          },
        ),
      );
    }
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: <Widget>[
        Wrap(
          
          children: inputWidget.toList(),
        ),
      ],
    );
  }
}
